<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport"
          content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no" />
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <title>列表</title>
    <link rel="stylesheet" href="../static/css/bootstrap.min.css" th:href="@{/css/bootstrap.min.css}" />
    <link rel="stylesheet" href="../static/layer/mobile/need/layer.css" th:href="@{/layer/mobile/need/layer.css}" />
    <link rel="stylesheet" href="../static/css/main.css" th:href="@{/css/main.css}" />
<!--    <link rel="stylesheet" href="../static/css/pagination.css" th:href="@{/css/pagination.css}" />-->
    <style>

    </style>
</head>

<body>
    <div class="header">
        <div class="container">
<!--            <img src="../static/image/banner.jpg"  th:src="@{image/banner.jpg}" alt=""/>-->
        </div>
    </div>

    <div class="searchBar clearfix">
        <div class="container clearfix">
            <div class="left">
                <label>当前行政执法单位：</label>
                <div class="item-select" id="item-select1">
                    <span class="select-val"></span>
                    <i class="carat"></i>
                    <ul class="item-select-list">
<!--                        <li class="active" id="">全部</li>-->
                    </ul>
                </div>
            </div>
            <div class="right">
                <a class="backIndex" ><span><</span>返回首页</a>
                <p class="date"></p>
                <img class="dateImg" th:src="@{image/date_icon.png}"  alt=""/>
            </div>
        </div>

    </div>

    <section class="section newlist-section clearfix">
         <div class="container">
        <div class="row">
            <div class="left col-md-3 col-sm-3 col-xs-3" id="navBar">
                <div class=""><img src="../static/image/home_list_icon_1@2x.png" th:src="@{image/home_list_icon_1@2x.png}" alt=""/>事前公开</div>
                <ul class="beforeTab">

                </ul>
                <div class=""><img src="../static/image/home_list_icon_1@2x.png" th:src="@{image/home_list_icon_1@2x.png}" alt=""/>事后公开</div>
                <ul class="afterTab">

                </ul>

<!--                <ul class="newTab">-->
<!--                    <div class=""><img src="../static/image/home_list_icon_1@2x.png" th:src="@{image/home_list_icon_1@2x.png}" alt=""/>行政复议公开</div>-->
<!--                    <li id="1"><span>行政复议申请</span><img class="arrow"  src="../static/image/home_list_icon_2@2x.png" th:src="@{image/home_list_icon_2@2x.png}" alt=""/></li>-->
<!--                    <li id="2" data-level1="1" data-lever2="101" ><span>事前公开</span><img  class="arrow"  src="../static/image/home_list_icon_2@2x.png" th:src="@{image/home_list_icon_2@2x.png}" alt=""/></li>-->
<!--                    <li id="3" data-level1="2" data-lever2="102" ><span>事后公开</span><img class="arrow"  src="../static/image/home_list_icon_2@2x.png" th:src="@{image/home_list_icon_2@2x.png}" alt=""/></li>-->
<!--                </ul>-->
            </div>
            <div class="right col-md-9 col-sm-9 col-xs-9">
                <div class="itemList">
                    <div class="subname">
                        全部
                    </div>
                    <ul id="item">
                    </ul>

                    <div id="p2" class="text-center" style="">
                        <ul id="page" class="pagination"></ul>
                    </div>
                </div>

            </div>
        </div>
    </div>
    </section>
<script src="../static/js/jquery-3.4.1.min.js" th:src="@{js/jquery-3.4.1.min.js}"></script>
<script src="../static/js/common.js"  th:src="@{js/common.js}"></script>
<script src="../static/js/bootstrap.min.js"  th:src="@{js/bootstrap.min.js}"></script>
<script src="../static/layer/layer.js"  th:src="@{layer/layer.js}"></script>
<script src="../static/js/jqPaginator.js"  th:src="@{js/jqPaginator.js}"></script>
<script type="text/javascript">


$('.backIndex').click(function(){
    window.location.href="/index";
})

var index = 1;
var formType = getUrlParam('formType');

var level1 = getUrlParam('level1');//一级id
var level2 = getUrlParam('level2');//二级id

var unitName = getUrlParam('name');//单位name
var unitId = getUrlParam('id');//单位id

var names = getUrlParam('names');

var unitId = getUrlParam('id');




var keywords = getUrlParam('keywords');//搜索
$('.subname').html(names)

var totalPage='';
var currentPage='';
var pageSize=12;

if(unitName==''||unitName=="undefined"){
    $('.select-val').html('全部').attr('id','');;
}else{
    $('.select-val').html(unitName).attr('id',unitId);
}

var currentTime=formatDate();
$('.date').html('今天是：'+currentTime);


$('#item-select1').click(function() {
    $('.item-select-list').toggleClass('active');
})

//4-首页 2-搜索 3-行政主体
    if(formType==3){
        getLevel_2(1,unitId);
        getLevel_2(2,unitId);
        search('','',level2,level1);
    }
    if(formType==2){
        getLevel_2(1,unitId);
        getLevel_2(2,unitId);
        search(keywords,'','','');
    }if(formType==4){
        getLevel_2(1,unitId);
        getLevel_2(2,unitId);
        search('',unitId,'','');
    }
// 获取下拉框值
$('.item-select-list').on('click', 'li', function() {
    // 获取点击了那个的值以及脚标
    var selectVal = $(this).text();
    var unitId = $(this).attr('id');
    $(this).addClass('active').siblings().removeClass('active');
    $('.select-val').html(selectVal).attr('id',unitId);
    var lv1Id=$('#navBar>ul>li.mark').attr('lv1id');
    var lv2Id=$('#navBar>ul>li.mark').attr('lv2id');
    search('',unitId,lv2Id,lv1Id,true);
    getLevel_2(1,unitId);
    getLevel_2(2,unitId);
})


  function search(keywords,unitId,level2,level1,flag) {
    $.post("/rqzf/search",
      {
        name: keywords,
        unitId:unitId,
        Lv2Id:level2,
        Lv1Id:level1,
        index:index,
        pageSize:pageSize,
      },
      function (ret) {
       if (flag) {
          $('#item').html('');
        }
          if(ret.success==0){
            var str = '';
            var data=ret.data;
            if(data&&data.length>0){
            data.forEach(function(val){
            str +=
            '<li title='+val.title+' resType='+val.resType+'   createTime='+val.createTime+'  unitName='+val.unitName+' id='+val.id+' resUrl='+val.resUrl+' >'+
                '<i class="point"></i>'+
               '<p>'+val.title+'</p>'+
               '<span>'+val.createTime+'</span>'+
          '</li> ';
          });
           $('#item').html(str);
            totalPage=ret.totalPage; //总页数
            currentPage=ret.page; //当前页数
			pageSize =ret.pageSize;//每页记录数

             $.jqPaginator('#page', {
                    totalPages: Number(totalPage),
                    visiblePages: Number(pageSize),
                    currentPage: Number(currentPage),
                    prev: '<li class="prev"><a href="javascript:;">上一页</a></li>',
                    next: '<li class="next"><a href="javascript:;">下一页</a></li>',
                    page: '<li class="page"><a href="javascript:;">{{page}}</a></li>',
                    onPageChange: function (num, type) {
                      if(type=='init'){/*初始化时，type为init。这里初始化时，不需要进行请求。*/
                        return;
                      }else{
                      index=num;
                      var lv1Id=$('#navBar>ul>li.mark').attr('lv1id');
                      var lv2Id=$('#navBar>ul>li.mark').attr('lv2id');
                      var unitId=$('.select-val').attr('id');
                       search('',unitId,lv2Id,lv1Id,true);
                      }
                    }
             });
             }else{
                 $('#item').html('<div class="noData">暂无内容~</div>');
                 $('#page').jqPaginator('destroy');
             }
        }
      })
  }

getAll();
  function getAll(){
    $.ajax({
      url: "/rqzf/getUnit",
      method:'GET',
      success:function(ret){
        if(ret.success==0){
          var str = '';
          var data=ret.data;
          data.forEach(function(val){
            str +=
              '<li id='+val.id+' name='+val.name+'>'+val.name+'</li>';
          });
          $('.item-select-list').append(str);
        }
      }
    })
  }


  function getLevel_2(Lv1Id,unitId) {
    $.post("/rqzf/getRenQiuLv2",
      {
        Lv1Id:Lv1Id,
        index:index,
        pageSize:30,
        unitId:unitId,
      },
      function (ret) {
        if(ret.success==0){
          var str = '';
          var data=ret.data;
          data.forEach(function(val){
          var className=(val.id==level2?'mark':'');
          var url=val.url;
          if(url==""||url==null||url==undefined){
            url=null;
          }
            str +='<li url='+url+'  lv1Id='+val.lv1Id+'  lv2Id='+val.id+'  name='+val.name+'  class='+className+' >'+
                      '<span>'+val.name+'</span>'+
                      '<img class="arrow"  src="/image/home_list_icon_2@2x.png"  alt=""/>'+
                  '</li>';
          });
          if(Lv1Id==1){
             $('.beforeTab').html(str);
          }
          if(Lv1Id==2){
           $('.afterTab').html(str);
          }
        }
      })
  }


<!--左侧-->
  $('.beforeTab').on('click', 'li', function() {
    var url=$(this).attr('url');
    if(url=='null'||url==""){
      var name=$(this).attr('name');
      $('.newlist-section .right .subname').html('事前公开>'+name);
      $('.newlist-section .left ul>li').removeClass('mark');
      $(this).addClass('mark');
      var lv2Id=$(this).attr('lv2Id');
      var Lv1Id =1;
      var unitId=$('.select-val').attr('id');
      search('',unitId,lv2Id,1,true);
    }else{
       window.location.href=url;
    }
  });

 $('.afterTab').on('click', 'li', function() {
    var url=$(this).attr('url');
    if(url=='null'||url==""){
        var name=$(this).attr('name');
        $('.newlist-section .right .subname').html('事后公开>'+name);
        $('.newlist-section .left ul>li').removeClass('mark');
        $(this).addClass('mark');
        var lv2Id=$(this).attr('lv2Id');
        var unitId=$('.select-val').attr('id');
        search('',unitId,lv2Id,2,true);
    }else{
       window.location.href=url;
    }
  });

  <!--右侧跳转-->
$('.right ul').on('click', 'li', function() {
    var resType=$(this).attr('resType');
    var title=$(this).attr('title');
    var createTime=$(this).attr('createTime');
    var unitName=$(this).attr('unitName');
    var resUrl=$(this).attr('resUrl');
    var id=$(this).attr('id');
    window.location.href='details'+'/'+id;
 });



  $('.applyTo').click(function(){
        window.location.href='apply_step1'
  })
</script>
</body>

</html>
